export const GAME_START = 'GAME_START'
export const GAME_INPUT_STEP = 'GAME_INPUT_STEP'
export const GAME_FINISH_ANSWER = 'GAME_FINISH_ANSWER'
export const GAME_RESTART = 'GAME_RESTART'

export class CellCoordinate {   // 解析坐标"startPoint": "1,1_right",
	public x: number;
	public y: number;
	public d: string;

	public constructor(coorData: string) {
		const arr = coorData.split(',');
		this.y = parseInt(arr[0].split('_')[0]),
		this.x = parseInt(arr[1].split('_')[0]),
		this.d = arr[1].split('_')[1]
	}
}

export interface GameState {
	cellWidth?: number								// 元素大小
	finished?: boolean               	// 是否完成输入
	currentInputIdx?: number					// 当前输入的答案步骤
	selectInputIdxs?: Array<number>  	// 已选的输入
	startCoor?: CellCoordinate				// 起点坐标
	endCoor?: CellCoordinate					// 终点坐标
	hurdles?: Array<cc.Vec2>					// 占位的坐标列表
	answer?: Array<string>						// 正确答案列表 ['T_right', 'T_right']
	inputs?: Array<string>						// 输入列表，根据答案随机生成
	inputPositions?: Array<cc.Vec2>		// 每一个输入项的坐标
	inputSpacing?: number							// 每个输入项的间距
	inputStartVec2?: cc.Vec2					// 输入项起始坐标
	playing?: boolean									// 是否游戏中
}

interface gameStartAction {
  type: typeof GAME_START
  initGameData: GameState
}
interface gameInputAction {
  type: typeof GAME_INPUT_STEP
	inputIndex: number
}
interface gameFinishAnswerAction {
  type: typeof GAME_FINISH_ANSWER
  finished: boolean
}
interface gameRestartAnswerAction {
  type: typeof GAME_RESTART
}

export type GameAtionTypes = gameStartAction | gameInputAction | gameFinishAnswerAction | gameRestartAnswerAction